Notification
The Notification module in the Scripting app allows you to schedule, manage, and display local notifications with advanced trigger types, interactive actions, and rich UI capabilities.
Table of Contents
Scheduling Notifications
Use Notification.schedule to schedule a local notification. It supports content, triggers, tap behaviors, action buttons, rich UI, and delivery configurations:
Parameters
SystemImageIcon
Used to define notification icon using system image name and color.
systemImage: SFSymbol namecolor: Icon color
Notification Actions (actions)
The actions parameter defines action buttons that are shown when the user long-presses or expands the notification. Each action has a title and an optional URL to open when tapped.
Notification Action (NotificationAction)
title: Action button titleicon: Action button iconurl: URL to open when tappeddestructive: Whether the action is destructive
Tap Behavior (tapAction)
The tapAction parameter gives you precise control over what happens when the user taps the notification:
"none"– Do nothing when tapped{ type: "runScript", scriptName: string }– Run a different script{ type: "openURL", url: string }– Open a deep link or web page
If tapAction is not provided, the default behavior is to run the current script, and the notification details can be accessed using Notification.current.
Notification Triggers
TimeIntervalNotificationTrigger
Triggers a notification after a specified number of seconds.
timeInterval: Delay in secondsrepeats: Whether it repeatsnextTriggerDate(): Returns the next expected trigger date
CalendarNotificationTrigger
Triggers when the current date matches specific calendar components.
- Supports components like
year,month,day,hour, etc. - Useful for daily or weekly reminders
LocationNotificationTrigger
Triggers when entering or exiting a geographic region.
- Fires based on entering/exiting the specified circular region
Notification Actions
Use the actions array to define buttons shown when the notification is expanded:
- Use
Script.createRunURLScheme(...)to generate Scripting app URLs - Action buttons appear on long-press or pull-down
Rich Notifications with Custom UI
You can provide an interactive JSX interface:
- Set
customUI: truein theNotification.schedule()call - Create a
notification.tsxfile - Call
Notification.present(element)inside that file
Notification.present(element: JSX.Element): void
Must be called from notification.tsx. Renders the element as the expanded notification interface.
Example notification.tsx
Managing Notifications
NotificationInfo and Request Structure
Use Notification.current to get launch context when the script is opened from a notification tap:
NotificationRequest Fields
Comprehensive Example
This example demonstrates a full-featured notification with actions, rich UI, and repeated delivery.
Step 1: Schedule the Notification
Step 2: Define notification.tsx
Summary
The Notification API in the Scripting app supports:
- Time, calendar, and location-based triggers
- Actionable buttons and script redirection
- Tap behaviors via
tapAction - Rich notification UI via
notification.tsx - Full lifecycle management (deliver, remove, query)
